package com.yantong.service.impl;

import com.yantong.utils.PageUtils;
import com.yantong.pojo.ProjectExp;
import com.yantong.pojo.vo.ProjectExpVo;
import com.yantong.mapper.ProjectExpMapper;
import com.yantong.service.ProjectExpService;
import org.apache.ibatis.session.RowBounds;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;


/**
 * 项目系统模板说明实现模块
 * @author xiangyi
 * @date 2018/9/8.20:10
 */

@Component
public class ProjectExpServiceImpl implements ProjectExpService {

    private static final Logger logger = LoggerFactory.getLogger(ProjectExpServiceImpl.class);


    @Autowired
    private  ProjectExpMapper projectExpMapper;


    @Override
    @Transactional(rollbackFor = Exception.class)
    public   PageUtils<ProjectExp> listProjectExp(ProjectExpVo params, int offset, int limit) {
    	 PageUtils<ProjectExp> pageUtils = new PageUtils<>();
    	 int total = projectExpMapper.getTotal(params);
    	 if(total>0) {
    	   pageUtils.setTotal(total);
    	   pageUtils.setRows(projectExpMapper.list(params,new RowBounds(offset, limit)));
    	 }else {
    		 logger.info("没有模板数据");
    	 }
         return pageUtils;
    }
    
    /**
     * 查询
     * @param params
     * @return
     */
    public ProjectExp listProjectExp(ProjectExpVo params) {
    	return projectExpMapper.list(params);
    };
    
    
    /**
     * 添加
     * @param params
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public  int save(ProjectExpVo params) {
    	return projectExpMapper.insertSelective(params);
    };
    
    
    /**
     * 删除
     * @param params
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int remove(ProjectExpVo params) {
    	return projectExpMapper.deleteByPrimaryKey(params.getId());
    };
    
    /**
     * 更新
     * @param params
     * @return
     */
    @Override
    public  int update(ProjectExpVo params) {
    	return projectExpMapper.updateByPrimaryKeySelective(params);
    };

    @Override
    public ProjectExp getByKey(Long id) {
        return projectExpMapper.selectByPrimaryKey(id);
    }
}

